define(function(require, exports, module){
	require("resource/js/easyui/easyloader.js");
	require.async("resource/js/component/rules.js");
	require("resource/js/easyui/themes/icon.css");
	var ajax = require("resource/js/component/ajax.js");
	var initForm = function(){
		/*$("#userupd").form({
			url:BASEPATH+"/base/authoriza/user/updateSelfPro.htm",
			success:function(data){
				
			}
		});*/
		$("#btn-save").bind("click",function(){
			using(["form"],function(){
				if($("#userupd").form("validate")){
					//$("#userupd").form("submit");
					//取得form数据
					var req_data = $("#userupd").serializeJson();
					//加载加密js
					var MD5 = require("resource/js/component/md5.js");
					//对新密码加密
					var password = MD5.md5($("#password").val()).toUpperCase();
					//对原密码加密
					var oldPassword = MD5.md5($("#oldPassword").val()).toUpperCase();
					req_data.password = password;
					req_data.oldPassword = oldPassword;
					req_data.phone = $("#mobile").val();
					console.log(req_data);
					//提交数据
					ajax.init().success(function(code,msg,data){
						using(['messager'],function(){
							$.messager.alert(""+Obj.get('base.common.success.Systemprompt')+"",msg,'',function(){
								indexApp.exec("logout");
//								window.location.href=''+BASEPATH+'/view/base/main/login'  ;
							});
						});
					}).error(function(code,msg,data){
						if(msg!=""){
							using(['messager'],function(){
								$.messager.alert(""+Obj.get('base.common.success.Systemprompt')+"",msg);
							});
						}
					}).post(BASEPATH+"/base/authoriza/user/updPsd.htm",req_data);
				}
			});
		});
	}

//	验证码倒计时
	var miao = 60;
    function time(e){
    	
        if(miao == 0)
        {
            e.removeAttribute('disabled');
            e.value = ""+Obj.get('base.common.success.obtain')+Obj.get('base.common.success.Verification')+"";
            $('#time').css({"color":"#1E8CFB"});
            clearTimeout(Account);
            miao = 60;
        }
        else
        {
            e.setAttribute("disabled", true);
            e.value=""+Obj.get('base.common.success.please')+""+ miao +""+Obj.get('base.common.success.secondscode')+"";
            $('#time').css({"color":"#666"});
            miao--;

            Account = setTimeout(function(){
                time(e);
            },1000);
        }
    }
    $('#time').click(
    	function(){time(this);
    })
//    重置
	$("#rtn-reset").click(function(){
		$("#userupd").form('clear');
	});    
	var initUser = function(){
		if(indexApp)
			indexApp.exec("user",function(user){
				$("#userupd").form("load",user);
			});
	}
	
	
	
	
	exports.init=function(){
		using(["textbox","form","combobox"],function(){
			initUser();
			initForm();
		});
	}	
});



















